<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>牛舍管理</title>
		
		<link href="css/mui.min.css" rel="stylesheet" type="text/css">
		<link href="css/new_file.css" rel="stylesheet" type="text/css">
	
		
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script src="js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>
		<script charset="UTF-8" src="js/mui.min.js"></script>
		<script src="js/jquery.qrcode.min.js"></script>
		<script src="js/qrcode.js"></script>
		<script src="js/jquery.qrcode.js"></script>
	</head>

	<body>
		
			<div class="head-zhjf">
			<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="fanhui()">
			<p style="color: white;size: 16px;">修改牛舍信息</p>
		    </div>
		    
     <div class="moban-lb">
     	<div class="moban-lb-l">
     		<div class="ziduan-mb">牛舍名称</div>    	     		
     	</div>
     	<div class="moban-lb-r">
     		 <input id="CowName" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;" class="shuru-jine">  		
     	
     	</div>
     	<div class="clear"></div>
     </div>
     <div class="moban-lb">
     	<div class="moban-lb-l">
     		<div class="ziduan-mb">牛舍编号</div>    	     		
     	</div>
     	<div class="moban-lb-r">
     		 <input id="houseCode" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;" class="shuru-jine">  		
     	
     	</div>
     	<div class="clear"></div>
     </div>
       <div class="moban-lb">
     	<div class="moban-lb-l">
     		<div class="ziduan-mb">容量</div>    	     		
     	</div>
     	<div class="moban-lb-r">
     		 <input id="CowSize" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;" class="shuru-jine" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"> 		
     	
     	</div>
     	<div class="clear"></div>
     </div>
     
       <div class="moban-lb">
     	<div class="moban-lb-l">
     		<div class="ziduan-mb">位置</div>    	     		
     	</div>
     	<div class="moban-lb-r">
     		 <input id="CowPosition" type="text" placeholder="请输入" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" style="color:;" class="shuru-jine">  		
     	</div>
     	<div class="clear"></div>
     </div>
     
      <div class="moban-lb" onclick="Cowequipment()">
     	<div class="moban-lb-l">
     		<div class="ziduan-mb">阅读器选择</div>    	     		
     	</div>
     	<div class="moban-lb-r" >
     		 <input id="CowPosi" type="text" placeholder="请选择" onfocus="if(value==defaultValue){value='';this.style.color='#616573'}" onblur="if(!value){value=defaultValue;this.style.color='#dee3f0'}" class="shuru-jine">
     	</div>
     	<div class="clear"></div>
     </div>

     <div class="tijiao">
            <button type="button" class="tijiao-btn" onclick="modifyCowsh()">提交</button> 
     </div>
      <script>
      	

      	var CowshedNumber = JSON.parse(localStorage.getItem('CowshedNumber'));
      	var modifyCowshed = JSON.parse(localStorage.getItem('modifyCowshed'));
		if (CowshedNumber == 10) {
			var CowshedDeviceSN = JSON.parse(localStorage.getItem('CowshedDeviceSN'));
			console.log(CowshedDeviceSN)
			if (CowshedDeviceSN == '') {
				var str = modifyCowshed.deviceSN;
			}else {
				var str = CowshedDeviceSN.deviceSN;
			}
			var str1 = JSON.parse(localStorage.getItem('CowName'));
			var str4 = JSON.parse(localStorage.getItem('houseCode'));
			var str2 = JSON.parse(localStorage.getItem('CowSize'));
			var str3 = JSON.parse(localStorage.getItem('CowPosition'));
			$("#CowName").val(str1);
			$("#CowSize").val(str2); 
			$("#CowPosition").val(str3); 
			$("#CowPosi").val(str);
			$("#houseCode").val(str4);
		}else {
			
			console.log(modifyCowshed);
			$("#CowName").val(modifyCowshed.houseName);
			$("#houseCode").val(modifyCowshed.houseCode);
			$("#CowSize").val(modifyCowshed.capacity); 
			$("#CowPosition").val(modifyCowshed.address); 
			$("#CowPosi").val(modifyCowshed.deviceSN);
		}
      	
      	function Cowequipment(){
      		localStorage.setItem('CowName',JSON.stringify($("#CowName").val()));
      		localStorage.setItem('houseCode',JSON.stringify($("#houseCode").val()));
      		localStorage.setItem('CowSize',JSON.stringify($("#CowSize").val()));
      		localStorage.setItem('CowPosition',JSON.stringify($("#CowPosition").val()));

      		localStorage.setItem('CowshedNumber',JSON.stringify(10));
      		equipments();
      	}
      	function fanhui(){
      		localStorage.setItem('CowshedNumber',JSON.stringify(0));
      		Cowshed();
      	}
      </script>
	</body>
</html>
